/*
* $Id: AddChangeInspectView.cpp 162 2010-10-04 11:21:18Z volok-aleksej@yandex.ru $
*
* Copyright 2008-2010 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "AddChangeInspectView.h"
#include "Event/EventId.h"
#include "ViewFieldValuesHelper.h"
#include "Visual/UserMessage.h"
#include "Visual/Drawers/EditorDrawer/HeaderItem.h"
#include "Visual/Drawers/EditorDrawer/EditItem.h"
#include "Visual/Drawers/EditorDrawer/ComboBoxItem.h"
#include "Visual/Drawers/EditorDrawer/SectionItem.h"
#include "Visual/Journal/AddHousingDialog.h"
#include "Settings/Journal/RecordViewSettings.h"
#include "Settings/SettingControlIds.h"
#include "Settings/DinIntDefined.h"
#include "Components/Journal/HousingManager.h"

#pragma warning(disable: 4407)

#define TITLE_ID				1
#define DATE_INSPECT_ID			2
#define FRAME_INSPECT_ID		3
#define STRENGTH_INSPECT_ID		4
#define EBQ_INSPECT_ID			5
#define WAX_INSPECT_ID			6
#define AMBROSIA_INSPECT_ID		7
#define PUMP_INSPECT_ID			8
#define FEEDING_INSPECT_ID		9
#define DISEASES_INSPECT_ID		10
#define NOTE_INSPECT_ID			11
#define ADD_HIVE_ID				12
#define USER_FIELD_ID			13
#define HOUSING_FIELD_ID(i, j)	(i<<8)|j
#define HONEY_FIELD_ID			1
#define BROOD_FIELD_ID			2
#define OPEN_BROOD_FIELD_ID		3
#define CLOSE_BROOD_FIELD_ID	4
#define GOOGS_HONEY_FIELD_ID	5

#define ADD_HIVE	1
#define DELETE_HIVE	2
#define NON_ACTIVE	3

/************************************************************************/
/*                     CAddChangeInspectView                            */
/************************************************************************/
CAddChangeInspectView::CAddChangeInspectView(CState* pState)
: CAddChangeView(pState), m_nUserFields(0){
	IEventManager::GetEventManager()->SubscribeEvent(dynamic_cast<ISubscriber*>(this), HOUSING_DB_CHANGE_EVENT);
	IEventManager::GetEventManager()->SubscribeEvent(dynamic_cast<ISubscriber*>(this), INSPECT_STN_CHANGE_EVENT);
}

CAddChangeInspectView::~CAddChangeInspectView(){
	IEventManager::GetEventManager()->UnSubscribeEvent(dynamic_cast<ISubscriber*>(this), HOUSING_DB_CHANGE_EVENT);
	IEventManager::GetEventManager()->UnSubscribeEvent(dynamic_cast<ISubscriber*>(this), INSPECT_STN_CHANGE_EVENT);
}

void CAddChangeInspectView::GetCurValue(){
	m_aCurValues[DATE_INSPECT_ID] = m_editorDrawer.GetValueItem(DATE_INSPECT_ID);
	m_aCurValues[FRAME_INSPECT_ID] = m_editorDrawer.GetValueItem(FRAME_INSPECT_ID);
	m_aCurValues[STRENGTH_INSPECT_ID] = m_editorDrawer.GetValueItem(STRENGTH_INSPECT_ID);
	m_aCurValues[WAX_INSPECT_ID] = m_editorDrawer.GetValueItem(WAX_INSPECT_ID);
	m_aCurValues[EBQ_INSPECT_ID] = m_editorDrawer.GetValueItem(EBQ_INSPECT_ID);
	m_aCurValues[AMBROSIA_INSPECT_ID] = m_editorDrawer.GetValueItem(AMBROSIA_INSPECT_ID);
	m_aCurValues[PUMP_INSPECT_ID] = m_editorDrawer.GetValueItem(PUMP_INSPECT_ID);
	m_aCurValues[FEEDING_INSPECT_ID] = m_editorDrawer.GetValueItem(FEEDING_INSPECT_ID);
	m_aCurValues[DISEASES_INSPECT_ID] = m_editorDrawer.GetValueItem(DISEASES_INSPECT_ID);
	m_aCurValues[NOTE_INSPECT_ID] = m_editorDrawer.GetValueItem(NOTE_INSPECT_ID);
	for(int i = 1; i <= m_nUserFields; i++)
		m_aCurValues[USER_FIELD_ID + i] = m_editorDrawer.GetValueItem(USER_FIELD_ID + i);
	for(std::map<int, housing>::iterator it = m_aHousings.begin(); it != m_aHousings.end(); it++){
		m_aCurValues[HOUSING_FIELD_ID(it->first, BROOD_FIELD_ID)] = m_editorDrawer.GetValueItem(HOUSING_FIELD_ID(it->first, BROOD_FIELD_ID));
		m_aCurValues[HOUSING_FIELD_ID(it->first, HONEY_FIELD_ID)] = m_editorDrawer.GetValueItem(HOUSING_FIELD_ID(it->first, HONEY_FIELD_ID));
		m_aCurValues[HOUSING_FIELD_ID(it->first, OPEN_BROOD_FIELD_ID)] = m_editorDrawer.GetValueItem(HOUSING_FIELD_ID(it->first, OPEN_BROOD_FIELD_ID));
		m_aCurValues[HOUSING_FIELD_ID(it->first, CLOSE_BROOD_FIELD_ID)] = m_editorDrawer.GetValueItem(HOUSING_FIELD_ID(it->first, CLOSE_BROOD_FIELD_ID));
		m_aCurValues[HOUSING_FIELD_ID(it->first, GOOGS_HONEY_FIELD_ID)] = m_editorDrawer.GetValueItem(HOUSING_FIELD_ID(it->first, GOOGS_HONEY_FIELD_ID));
	}
}

void CAddChangeInspectView::GetSaveData(CInspectManager::journal& jrn,
		std::vector<CInspectManager::inspect>& aInspect, std::map<std::tstring, std::tstring>& aUserField){
	jrn.m_date = CConvertFunction::ConvertFromDate(m_editorDrawer.GetValueItem(DATE_INSPECT_ID));
	jrn.m_nFrame = _ttoi(m_editorDrawer.GetValueItem(FRAME_INSPECT_ID).c_str());
	jrn.m_nStrength = _ttoi(m_editorDrawer.GetValueItem(STRENGTH_INSPECT_ID).c_str());
	jrn.m_nWax = _ttoi(m_editorDrawer.GetValueItem(WAX_INSPECT_ID).c_str());
	jrn.m_nQBState = (Journal::queen_bee)_ttoi(m_editorDrawer.GetValueItem(EBQ_INSPECT_ID).c_str());
	jrn.m_nAmbrosia = _ttoi(m_editorDrawer.GetValueItem(AMBROSIA_INSPECT_ID).c_str());
	jrn.m_nEvacuation = _ttoi(m_editorDrawer.GetValueItem(PUMP_INSPECT_ID).c_str());
	jrn.m_nDieting = _ttoi(m_editorDrawer.GetValueItem(FEEDING_INSPECT_ID).c_str());
	jrn.m_nDisease = (Journal::disease)_ttoi(m_editorDrawer.GetValueItem(DISEASES_INSPECT_ID).c_str());
	jrn.m_strNote = m_editorDrawer.GetValueItem(NOTE_INSPECT_ID);
	for(int i = 1; i <= m_nUserFields; i++)
		aUserField.insert(std::make_pair(m_editorDrawer.GetNameItem(USER_FIELD_ID + i), m_editorDrawer.GetValueItem(USER_FIELD_ID + i)));
	for(std::map<int, housing>::iterator it = m_aHousings.begin(); it != m_aHousings.end(); it++){
		CInspectManager::inspect ins;
		ins.m_nBrood = _ttoi(m_editorDrawer.GetValueItem(HOUSING_FIELD_ID(it->first, BROOD_FIELD_ID)).c_str());
		ins.m_nHoney = _ttoi(m_editorDrawer.GetValueItem(HOUSING_FIELD_ID(it->first, HONEY_FIELD_ID)).c_str());
		ins.m_nOpenBrood = _ttoi(m_editorDrawer.GetValueItem(HOUSING_FIELD_ID(it->first, OPEN_BROOD_FIELD_ID)).c_str());
		ins.m_nCloseBrood = _ttoi(m_editorDrawer.GetValueItem(HOUSING_FIELD_ID(it->first, CLOSE_BROOD_FIELD_ID)).c_str());
		ins.m_nGoodHoney = _ttoi(m_editorDrawer.GetValueItem(HOUSING_FIELD_ID(it->first, GOOGS_HONEY_FIELD_ID)).c_str());
		ins.m_nIdHousing = it->second.m_nId;
		ins.m_strNameHousing = it->second.m_strName;
		aInspect.push_back(ins);
	}
}

void CAddChangeInspectView::Init(){
	m_aHousings.clear();
	m_nCountHousing = 1;

	m_editorDrawer.Clear();
	m_editorDrawer.AddItem(new CHeaderItem(GetHeaderString(), TITLE_ID));

	m_editorDrawer.AddItem(new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_DATE_ID), DATE_INSPECT_ID, editItem::DATE, m_aCurValues[DATE_INSPECT_ID]));
	m_editorDrawer.AddItem(new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_FRAME_ID), FRAME_INSPECT_ID, editItem::INTEGER, m_aCurValues[FRAME_INSPECT_ID]));
	m_editorDrawer.AddItem(new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_BEES_ID), STRENGTH_INSPECT_ID, editItem::INTEGER, m_aCurValues[STRENGTH_INSPECT_ID]));
	CComboBoxItem* pComboItem = new CComboBoxItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_EBQ_ID), EBQ_INSPECT_ID);
	pComboItem->AddValueItem(Journal::DEFAULT, ILanguageManager::GetLanguageManager()->GetString(QUEEN_BEE_STATUS_DEFAULT_ID));
	pComboItem->AddValueItem(Journal::LOOK, ILanguageManager::GetLanguageManager()->GetString(QUEEN_BEE_STATUS_LOOK_ID));
	pComboItem->AddValueItem(Journal::ABSENCE, ILanguageManager::GetLanguageManager()->GetString(QUEEN_BEE_STATUS_ABSENCE_ID));
	pComboItem->AddValueItem(Journal::FETAL, ILanguageManager::GetLanguageManager()->GetString(QUEEN_BEE_STATUS_FETAL_ID));
	pComboItem->SetValue(_ttoi(m_aCurValues[EBQ_INSPECT_ID].c_str()));
	m_editorDrawer.AddItem(pComboItem);
	CRecordViewSettings jSettings;
	CEditItem* pItem = new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_WAX_ID), WAX_INSPECT_ID, editItem::INTEGER, m_aCurValues[WAX_INSPECT_ID]);
	m_editorDrawer.AddItem(pItem);
	if(jSettings.GetCurrentValue(CHECK_GIVE_WOX_ID) != CHECK_BOX_STATE_1)
		pItem->Hide(true);
	pItem = new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_AMBROSIA_ID), AMBROSIA_INSPECT_ID, editItem::INTEGER, m_aCurValues[AMBROSIA_INSPECT_ID]);
	m_editorDrawer.AddItem(pItem);
	if(jSettings.GetCurrentValue(CHECK_AMBROSIA_ID) != CHECK_BOX_STATE_1)
		pItem->Hide(true);
	pItem = new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_PUMP_HONEY_ID), PUMP_INSPECT_ID, editItem::INTEGER, m_aCurValues[PUMP_INSPECT_ID]);
	m_editorDrawer.AddItem(pItem);
	if(jSettings.GetCurrentValue(CHECK_PUMP_HONEY_ID) != CHECK_BOX_STATE_1)
		pItem->Hide(true);
	pItem = new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_FEEDING_ID), FEEDING_INSPECT_ID, editItem::INTEGER, m_aCurValues[FEEDING_INSPECT_ID]);
	m_editorDrawer.AddItem(pItem);
	if(jSettings.GetCurrentValue(CHECK_FEEDING_ID) != CHECK_BOX_STATE_1)
		pItem->Hide(true);
	pComboItem = new CComboBoxItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_DISEASES_ID), DISEASES_INSPECT_ID);
	for(int i = 0, id = DISEASE_HEALTHY_ID; i < 33; i++, id++)
		pComboItem->AddValueItem(i, ILanguageManager::GetLanguageManager()->GetString(id));
	pComboItem->SetValue(_ttoi(m_aCurValues[DISEASES_INSPECT_ID].c_str()));
	m_editorDrawer.AddItem(pComboItem);
	if(jSettings.GetCurrentValue(CHECK_DISEASES_ID) != CHECK_BOX_STATE_1)
		pComboItem->Hide(true);
	pItem = new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_NOTE_ID), NOTE_INSPECT_ID, editItem::TEXT, m_aCurValues[NOTE_INSPECT_ID]);
	m_editorDrawer.AddItem(pItem);
	if(jSettings.GetCurrentValue(CHECK_NOTE_ID) != CHECK_BOX_STATE_1)
		pItem->Hide(true);

	CViewFieldValuesHelper helper(&m_editorDrawer);
	m_nUserFields = helper.GenerateUserEditItems(TypeField::INSPECT, USER_FIELD_ID, m_nIdRecord, m_aCurValues);

	GetHousings();
	for(std::map<housing, int>::iterator it = m_aHousingUser.begin(); it != m_aHousingUser.end(); it++){
		if(it->second == ADD_HIVE){
			m_aHousings.insert(std::make_pair(m_nCountHousing, housing(it->first.m_nId, it->first.m_strName)));
			AddHousingFields();
			m_nCountHousing++;
		}else if(it->second == NON_ACTIVE)
			m_nCountHousing++;
	}
	if(m_aHousings.empty())
		EnableSaveButton(false);
	else
		EnableSaveButton(true);
	CSectionItem* pItem1 = new CSectionItem(_T(""), &m_editorDrawer, ADD_HIVE_ID);
	pItem1->AddButton(ILanguageManager::GetLanguageManager()->GetString(ADD_ID));
	m_editorDrawer.AddItem(pItem1);
}

void CAddChangeInspectView::AddHousingFields(){
	CSectionItem* pItem1 = new CSectionItem(ILanguageManager::GetLanguageManager()->GetString(HOUSING_ID) + _T(" ") + m_aHousings[m_nCountHousing].m_strName, &m_editorDrawer, HOUSING_FIELD_ID(m_nCountHousing, 0));
	pItem1->AddButton(ILanguageManager::GetLanguageManager()->GetString(DELETE_ID));
	m_editorDrawer.AddItem(pItem1);
	m_editorDrawer.AddItem(new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_BROOD_ID), HOUSING_FIELD_ID(m_nCountHousing, BROOD_FIELD_ID), editItem::INTEGER, m_aCurValues[HOUSING_FIELD_ID(m_nCountHousing, BROOD_FIELD_ID)]));
	m_editorDrawer.AddItem(new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_HONEY_ID), HOUSING_FIELD_ID(m_nCountHousing, HONEY_FIELD_ID), editItem::INTEGER, m_aCurValues[HOUSING_FIELD_ID(m_nCountHousing, HONEY_FIELD_ID)]));
	CEditItem* pItem = new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_OPEN_BROOD_ID), HOUSING_FIELD_ID(m_nCountHousing, OPEN_BROOD_FIELD_ID), editItem::INTEGER, m_aCurValues[HOUSING_FIELD_ID(m_nCountHousing, OPEN_BROOD_FIELD_ID)]);
	m_editorDrawer.AddItem(pItem);
	CRecordViewSettings jSettings;
	if(jSettings.GetCurrentValue(CHECK_OPEN_BROOD_ID) != CHECK_BOX_STATE_1)
		pItem->Hide(true);
	pItem = new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_CLOSE_BROOD_ID), HOUSING_FIELD_ID(m_nCountHousing, CLOSE_BROOD_FIELD_ID), editItem::INTEGER, m_aCurValues[HOUSING_FIELD_ID(m_nCountHousing, CLOSE_BROOD_FIELD_ID)]);
	m_editorDrawer.AddItem(pItem);
	if(jSettings.GetCurrentValue(CHECK_SEAL_BROOD_ID) != CHECK_BOX_STATE_1)
		pItem->Hide(true);
	pItem = new CEditItem(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_GOODS_HONEY_ID), HOUSING_FIELD_ID(m_nCountHousing, GOOGS_HONEY_FIELD_ID), editItem::INTEGER, m_aCurValues[HOUSING_FIELD_ID(m_nCountHousing, GOOGS_HONEY_FIELD_ID)]);
	m_editorDrawer.AddItem(pItem);
	if(jSettings.GetCurrentValue(CHECK_GOODS_HONEY_ID) != CHECK_BOX_STATE_1)
		pItem->Hide(true);
}

void CAddChangeInspectView::AddHousing(housing hive){
	std::map<housing, int>::iterator it1 = m_aHousingUser.find(hive);
	if(it1 != m_aHousingUser.end() && it1->second == DELETE_HIVE){
		m_nCountHousing++;
		return;
	}
	if(it1 != m_aHousingUser.end() && it1->second == ADD_HIVE)
		m_aHousingUser.erase(it1);
	m_aHousings.insert(std::make_pair(m_nCountHousing, hive));
	AddHousingFields();
	m_nCountHousing++;
}

BEGIN_MESSAGE_MAP(CAddChangeInspectView, CAddChangeView)
	ON_WM_CREATE()
	ON_MESSAGE(UM_BUTTONCLICK, OnButtonClick)
END_MESSAGE_MAP()

afx_msg int CAddChangeInspectView::OnCreate(LPCREATESTRUCT lpCreateStruct){
	m_aHousingUser.clear();
	return __super::OnCreate(lpCreateStruct);
}

afx_msg LRESULT CAddChangeInspectView::OnButtonClick(WPARAM wParam, LPARAM lParam){
	if(wParam == ADD_HIVE_ID){
		CAddHousingDialog dialog(this);
		if(dialog.DoModal() == IDOK){
			int nId = 0;
			std::tstring strName;
			dialog.GetHousing(nId, strName);
			housing hive(nId, strName);
			std::map<housing, int>::iterator it = m_aHousingUser.find(hive);
			if(it != m_aHousingUser.end() && it->second == DELETE_HIVE)
				m_aHousingUser.erase(it);
			else
				m_aHousingUser[hive] = ADD_HIVE;
		}else
			return 0;
	}
	else if(MessageBox((ILanguageManager::GetLanguageManager()->GetString(QUESTION_DELETE_ID) +
		_T(" '") + m_aHousings[HIBYTE((WORD)wParam)].m_strName + _T("'.")).c_str(),
		ILanguageManager::GetLanguageManager()->GetString(DELETE_HOUSING_ID).c_str(), MB_OKCANCEL) == IDOK){
			std::map<housing, int>::iterator it = m_aHousingUser.find(m_aHousings[HIBYTE((WORD)wParam)]);
			if(it == m_aHousingUser.end())
				m_aHousingUser.insert(std::make_pair(m_aHousings[HIBYTE((WORD)wParam)], DELETE_HIVE));
			else if(it->second == ADD_HIVE)
				it->second = NON_ACTIVE;
	}
	EventHandler();
	Invalidate(FALSE);
	return 0;
}


/************************************************************************/
/*                         CAddInspectView                              */
/************************************************************************/
CAddInspectView::CAddInspectView(CState* pState)
: CAddChangeInspectView(pState){}
CAddInspectView::~CAddInspectView(){}

void CAddInspectView::SetState(){
	m_pState->m_nState = Journal::VIEW_ADD_INSPECT;
}
bool CAddInspectView::IsViewState(State state){
	return state.m_type == Journal::ADD_INSPECT;
}
std::tstring CAddInspectView::GetHeaderString(){
	return ILanguageManager::GetLanguageManager()->GetString(ADD_INSPECT_ID);
}

BEGIN_MESSAGE_MAP(CAddInspectView, CAddChangeInspectView)
	ON_COMMAND(BUTTON_SAVE_ID, OnSaveInspect)
END_MESSAGE_MAP()

afx_msg void CAddInspectView::OnSaveInspect(){
	CInspectManager* pManager = IJournalComponent::GetInspectManager();
	CInspectManager::journal jrn;
	std::vector<CInspectManager::inspect> aInspect;
	std::map<std::tstring, std::tstring> aUserField;
	GetSaveData(jrn, aInspect, aUserField);
	jrn.m_nIdFamily = m_nIdParameter;
	pManager->AddInspect(jrn, aInspect, aUserField);
	__super::OnCancel();
}

void CAddInspectView::GetHousings(){
	std::map<int, CHousingManager::housing> aHousing  = IJournalComponent::GetHousingManager()->GetFamilyHousings(m_nIdParameter);
	for(std::map<int, CHousingManager::housing>::iterator it = aHousing.begin(); it != aHousing.end(); it++)
		AddHousing(housing(it->first, it->second.m_strName));
}
/************************************************************************/
/*                       CChangeInspectView                             */
/************************************************************************/
CChangeInspectView::CChangeInspectView(CState* pState)
: CAddChangeInspectView(pState){
	m_nIdRecord = 0;
}
CChangeInspectView::~CChangeInspectView(){}

void CChangeInspectView::SetState(){
	m_pState->m_nState = Journal::VIEW_CHANGE_INSPECT;
}
bool CChangeInspectView::IsViewState(State state){
	return state.m_type == Journal::CHANGE_INSPECT;
}
std::tstring CChangeInspectView::GetHeaderString(){
	return ILanguageManager::GetLanguageManager()->GetString(CHANGE_INSPECT_ID);
}

BEGIN_MESSAGE_MAP(CChangeInspectView, CAddChangeInspectView)
	ON_COMMAND(BUTTON_SAVE_ID, OnSaveInspect)
	ON_MESSAGE(UM_BUTTONCLICK, OnButtonClick)
END_MESSAGE_MAP()

void CChangeInspectView::OnSaveInspect(){
	CInspectManager* pManager = IJournalComponent::GetInspectManager();
	CInspectManager::journal jrn;
	std::vector<CInspectManager::inspect> aInspects;
	std::map<std::tstring, std::tstring> aUserFields;
	GetSaveData(jrn, aInspects, aUserFields);
	pManager->ChangeInspect(m_nIdParameter, jrn, aInspects, aUserFields);
	__super::OnCancel();
}

void CChangeInspectView::InitCurrentValue(){
	CInspectManager* pManager = IJournalComponent::GetInspectManager();
	CInspectManager::journal jrn = pManager->GetJournal(m_pState->m_nIdParameter);
	m_aCurValues[DATE_INSPECT_ID] = CConvertFunction::ConvertFromDate(jrn.m_date);
	m_aCurValues[FRAME_INSPECT_ID] = CConvertFunction::ConvertFromInt(jrn.m_nFrame);
	m_aCurValues[STRENGTH_INSPECT_ID] = CConvertFunction::ConvertFromInt(jrn.m_nStrength);
	m_aCurValues[EBQ_INSPECT_ID] = CConvertFunction::ConvertFromInt(jrn.m_nQBState);
	m_aCurValues[WAX_INSPECT_ID ] = CConvertFunction::ConvertFromInt(jrn.m_nWax);
	m_aCurValues[AMBROSIA_INSPECT_ID] = CConvertFunction::ConvertFromInt(jrn.m_nAmbrosia);
	m_aCurValues[PUMP_INSPECT_ID] = CConvertFunction::ConvertFromInt(jrn.m_nEvacuation);
	m_aCurValues[FEEDING_INSPECT_ID] = CConvertFunction::ConvertFromInt(jrn.m_nDieting);
	m_aCurValues[FEEDING_INSPECT_ID] = CConvertFunction::ConvertFromInt(jrn.m_nDisease);
	m_aCurValues[NOTE_INSPECT_ID] = jrn.m_strNote;
	m_nIdRecord = jrn.m_nIdRecord;
	std::vector<CInspectManager::inspect> aInspects = pManager->GetInspects(m_pState->m_nIdParameter);
	int j = 1;
	for(std::vector<CInspectManager::inspect>::iterator it = aInspects.begin(); it != aInspects.end();it++,j++){
		m_aCurValues[HOUSING_FIELD_ID(j, BROOD_FIELD_ID)] = CConvertFunction::ConvertFromInt(it->m_nBrood);
		m_aCurValues[HOUSING_FIELD_ID(j, HONEY_FIELD_ID)] = CConvertFunction::ConvertFromInt(it->m_nHoney);
		m_aCurValues[HOUSING_FIELD_ID(j, OPEN_BROOD_FIELD_ID)] = CConvertFunction::ConvertFromInt(it->m_nOpenBrood);
		m_aCurValues[HOUSING_FIELD_ID(j, CLOSE_BROOD_FIELD_ID)] = CConvertFunction::ConvertFromInt(it->m_nCloseBrood);
		m_aCurValues[HOUSING_FIELD_ID(j, GOOGS_HONEY_FIELD_ID)] = CConvertFunction::ConvertFromInt(it->m_nGoodHoney);
	}
}

void CChangeInspectView::GetHousings(){
	std::vector<CInspectManager::inspect> aInspects = IJournalComponent::GetInspectManager()->GetInspects(m_pState->m_nIdParameter);
	for(std::vector<CInspectManager::inspect>::iterator it = aInspects.begin(); it != aInspects.end();it++)
		AddHousing(housing(it->m_nIdHousing, it->m_strNameHousing));
}
